package kr.co.doriclassic.mypuppystory.kind;

import kr.co.doriclassic.mypuppystory.R;
import kr.co.doriclassic.mypuppystory.searchpuppy.SearchPuppy;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

public class KindIntent extends Activity {
	String kind, pic, content, kindcd;
	TextView tx1, tx2;
	ImageButton searchbtn;
	ImageView img;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.kind_intent);
		
		Intent intent = getIntent();
		kind = intent.getExtras().getString("kind");
		content = intent.getExtras().getString("content");
		pic = intent.getExtras().getString("img");
		kindcd = intent.getExtras().getString("kindcd");
		Log.d("kind", kindcd);
		
		tx1 = (TextView) findViewById(R.id.tx1);
		tx2 = (TextView) findViewById(R.id.tx2);
		img = (ImageView) findViewById(R.id.pic);
		searchbtn = (ImageButton)findViewById(R.id.search);
		
		tx1.setText(kind);
		tx2.setText(content);
		int res = getResources().getIdentifier(pic, "drawable",
				"kr.co.doriclassic.mypuppystory");
		if (res < 0)
			img.setVisibility(View.GONE);
		else
			img.setImageResource(res);
		
		searchbtn.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(KindIntent.this, SearchPuppy.class);
				intent.putExtra("kindcd", kindcd);
				startActivity(intent);
			}
		});
	}
}
